﻿@inherits ButtonsBlock<IViewModel>
@{
    var buttonSubmit = Model.MasterModel.ButtonSubmit;

    var content = new Div("divButtons")
    {
        // I. Submit button
        buttonSubmit.IsNull()
            ? null
            : new Div
            {
                new Button(buttonSubmit.Text.IsNotEmpty() ? buttonSubmit.Text : buttonSubmit.ButtonName)
                  .SetText(buttonSubmit.TextLocalized.IsNotEmpty() ? buttonSubmit.TextLocalized : null)
                  .SetName(buttonSubmit.ButtonName)
                  .SetAccessKey("s")
                  .SetTitle(GetTitle(buttonSubmit) + " (Shift + Alt + S)")
                  .SetAttribute("data-assuremessage", AssureDelete(buttonSubmit))
                  .AddCssClassName(AssureDelete(buttonSubmit).IsNotEmpty() ? "assure" : null)
                  .AddCssClassName(buttonSubmit.ButtonName)
                  .SetAttribute(Attr.Form, buttonSubmit.FormIdForJS)

            }
    }.SetId("masterButtons");

    // II. another buttons
    foreach (var button in Model.MasterModel.ButtonsModel.Buttons)
    {
        var div = new Div
        {
            new Form()
                .SetAction(GetFormActionUrl(button))
                .SetMethod(button.ButtonName.IsEqual(Str.Actions.Edit) ? MethodType.Get : MethodType.Post)
                .AddControls
                (
                    new Button(GetText(button), false)
                        .SetType(ButtonType.Submit)
                        .SetAccessKey(GetAccessKey(button))
                        .SetTitle(GetTitle(button))
                        .SetDisabled(button.IsDisabled)
                        //.SetName(button.ButtonName)
                        .SetAttribute(Attr.Form, button.FormIdForJS)
                        .SetAttribute("data-assuremessage", AssureDelete(button))
                        .AddCssClassName(AssureDelete(button).IsNotEmpty() ? "assure" : null)
                        .AddCssClassName(button.ButtonName)
                )
        };
        content.Add(div);
    };
}
@AddControls(content)